/**
 * Created by 白雨浓 on 2018/1/16 11:56.
 */

export default {
    install(Vue){
        /** 转下划线 */
        const toUnderline = (s) => {
            s = s.replace(/([A-Z])/g, "_$1").toLowerCase();
            if (s[0] === '_') s = s.substring(1);
            return s;
        };

        /** 转驼峰 */
        const toCamel = (s) => {
            return s.replace(/_(\w)/g, (all, letter) => letter.toUpperCase());
        };

        Vue.prototype.$str ={
            toUnderline,
            toCamel
        }
    }
}